home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_41200.txt < prev    next >
Text File  |  1991-02-27  |  2KB  |  106 lines

  1. -- card: 41200 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part 1 (field)
  9. -- low flags: 00
  10. -- high flags: 0007
  11. -- rect: left=30 top=78 right=296 bottom=478
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 0
  15. -- font id: 4
  16. -- text size: 9
  17. -- style flags: 0
  18. -- line height: 12
  19. -- part name: 
  20.  
  21.  
  22. -- part contents for card part 1
  23. ----- text -----
  24. /*
  25. *   FILE:    main.c
  26. *   AUTHOR:  R.G.
  27. *   CREATED: June 25, 1990
  28. *   
  29. *   main() function for class example
  30. *
  31. *   PROJECT CONTENTS:
  32. *   class.c, person.c, student.c, main.c
  33. *   (For Think C, add the ANSI and oops libraries.)
  34. */
  35.  
  36. # include "person.h"
  37. # include "student.h"
  38. # include <stdio.h>
  39. # include <oops.h>   /* DELETE THIS LINE FOR C++ */
  40.  
  41. char    get_choice(void);   /* prototype for later definition */
  42.  
  43. /******************************************************************
  44. *   main() function
  45. ******************************************************************/
  46. main()
  47. {
  48.     Person  *person[100];   /* array of Person-pointers */
  49.     char    response;
  50.     int     i = 0,
  51.             j;
  52.  
  53.     while (i<100 && ((response=get_choice()) != 'x'))
  54.     {
  55.         if (response == 'p')
  56.             person[i++] = new(Person);
  57.         else if (response == 's')
  58.             person[i++] = new(Student);
  59.     }
  60.  
  61.     for (j=0 ; j<i ; j++)
  62.     {
  63.         printf("\nPerson #%d:\n",j);
  64.         if (person[j] != NULL)
  65.         {
  66.             person[j]->init();
  67.             person[j]->set();
  68.         }
  69.     }
  70.  
  71.     for (j=0 ; j<i ; j++)
  72.     {
  73.         printf("\nPerson #%d:\n",j);
  74.         if (person[j] != NULL)
  75.         {
  76.             person[j]->print();
  77.             printf("\n");
  78.             person[j]->destroy();
  79.         }
  80.         delete(person[j]);
  81.     }
  82. }
  83.  
  84. /******************************************************************
  85. *   function to get choice from user
  86. ******************************************************************/
  87. char    get_choice(void)
  88. {
  89.     char    response,
  90.             junk;
  91.  
  92.     printf("Add a person (p), student (s), or exit (x):\n");
  93.     scanf("%c",&response);
  94.     scanf("%c",&junk);       /* get unneeded linefeed character */
  95.     return response;
  96. }
  97.  
  98.  
  99.  
  100. -- part contents for background part 7
  101. ----- text -----
  102. 137
  103.  
  104. -- part contents for background part 4
  105. ----- text -----
  106. File 7 of 7: